// JavaScript Document
  var baseUrl;
  $(document).ready(function(){
		var aTextDiv = getObjectByClass('pre','atext');
		for(var i = 0; i < aTextDiv.length; i++){
			aTextDiv[i].innerText = aTextDiv[i].innerText.replaceAll("/r","</br>");
		}
	});
	
	function getObjectByClass(tagName,sName){
		var oClass = [];
		var oTag = document.getElementsByTagName(tagName);
		for(var i=0; i<oTag.length; i++){	
		var sClass = oTag[i].className;
			if(sClass == sName){
				oClass.push(oTag[i]);
			}
		}
		return oClass;
	};
	
	String.prototype.replaceAll  = function(s1,s2){   
		return this.replace(new RegExp(s1,"gm"),s2);   
	} 
	
	
	
//地区切换选项
function Sha(ID){
for(i=0;i<22;i++){
 if(ID==i){
  abcz[ID].className='zkw_title_on';
  abcdz[ID].style.display='block';
 }
 else{
  abcz[i].className='zkw_title';
  abcdz[i].style.display='none';
 }
 }
} 

	function openNewWin(owurl){
	var tmp=window.open("about:blank","","height=680, width=1140, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=yes, status=no");
	tmp.focus();
	tmp.location=owurl;
}

//tab切换
$(function() {
 function tt() {
 var td = $(this);
 var t = td.attr("id");
 var tds = td.parent("tr").find("td");
 var tables = td.parents("div:eq(0)");
 var table = tables.find("#div_" + t);
 tds.attr("className", "Lanmititle");
 td.attr("className", "Lanmititletihuan");
tables.find("div[id*=div_t]").css("display", "none");
 tables.find("#div_" + t).css("display", "block");
 }
 $(".Lanmititletihuan[id*=t]").mouseover(tt);
  $(".Lanmititle[id*=t]").mouseover(tt);
 });

//表格触碰颜色切换
$(document).ready(function(){
	$(".xdTab tr").mouseover(function(){
     $(this).addClass("over");
    }).mouseout(function(){
     $(this).removeClass("over");
    })
	});	
	
//搜索默认值
// JavaScript Document
//文本框提示信息激活清空
function cls(){ 
//捕获触发事件的对象，并设置为以下语句的默认对象 
with(event.srcElement) 
    //如果当前值为默认值，则清空 
if(value==defaultValue) value="" 
} 
function res(){ 
//捕获触发事件的对象，并设置为以下语句的默认对象 
with(event.srcElement) 
//如果当前值为空，则重置为默认值 
if(value=="") value=defaultValue 
} 
function setR(index) {
    for (var i = 0; i < 4; i++) {
        if (index != i) {
            $("#rm" + i).attr("className", "r-td");
        }
    }
    for (var i = 0; i < 4; i++) {
        if (index != i) {
            $("#r" + i).css("display", "none");
        }
    }
    $("#rm" + index).attr("className", "r-sel");
    $("#r" + index).css("display", "block");
}
function setY(index) {
    for (var i = 0; i < 4; i++) {
        if (index != i) {
            $("#ym" + i).attr("className", "y-td");
        }
    }
    for (var i = 0; i < 4; i++) {
        if (index != i) {
            $("#y" + i).css("display", "none");
        }
    }
    $("#ym" + index).attr("className", "y-sel");
    $("#y" + index).css("display", "block");
}
//关闭DIV层
function closeSearchBar(){
	ymPrompt.close();
    void(0);
}
function onMouseOver(){
    $(".cur-sub-con").removeClass("cur-sub-con");
    $(".sub-con").eq($(".nav li a").index(curLi)).addClass("cur-sub-con");
    $(".cur").removeClass("cur");
    curLi.addClass("cur");
}
function comGetVillageDep(){
	$("#comDep").empty();
	$("#comDep").append("<option value=''>--部&nbsp;门--</option>");
  	$.get(baseUrl+"/department/getDepsForAdSearch/"+$("#comVillage").val(), function(data){
  	  	var deps = eval(data);
  		for(var j = 0; j < deps.length; j++){
			$("#comDep").append("<option value="+deps[j].depId+">"+deps[j].departmentName+"</option>");
		}
  	});
}
function comGetVillageNameAndDep(){
	$("#comVillage").empty();
	$("#comVillage").append("<option value=''>--县、区--</option>");
	eval("var city = p"+$("#comCity").val());
	alert(comVillageVal);
	  	for(var i = 0; i < city.length; i++){
	  		var _value = city[i][0];
			if(comVillageVal && comVillageVal != '' && comVillageVal == _value){
				$("#comVillage").append("<option value="+city[i][0]+" selected='selected'>"+city[i][1]+"</option>");
			}else{
				$("#comVillage").append("<option value="+city[i][0]+">"+city[i][1]+"</option>");
			}
		}
	$("#comDep").empty();
	$("#comDep").append("<option value=''>--部&nbsp;门--</option>");
	var _comCityVal = $("#comCity").val();
	var _comVillage = $("#comVillage").val();
	var _code;
	if(_comVillage && _comVillage != ''){
		_code = _comVillage;
	}else{
		_code = _comCityVal;
	}
  	$.get(baseUrl+"/department/getDepsForAdSearch/"+_code, function(data){
  	  	var deps = eval(data);
  		for(var j = 0; j < deps.length; j++){
  			var _value = deps[j].depId;
			if(comDepVal && comDepVal != '' && comDepVal == _value){
				$("#comDep").append("<option value="+deps[j].depId+" selected='selected'>"+deps[j].departmentName+"</option>");
			}else{
				$("#comDep").append("<option value="+deps[j].depId+">"+deps[j].departmentName+"</option>");
			}
		}
  	});
};
function perGetVillageDep(){
	$("#perDep").empty();
	$("#perDep").append("<option value=''>--部&nbsp;门--</option>");
  	$.get(baseUrl+"/department/getDepsForAdSearch/"+$("#perVillage").val(), function(data){
  	  	var deps = eval(data);
  		for(var j = 0; j < deps.length; j++){
			$("#perDep").append("<option value="+deps[j].depId+">"+deps[j].departmentName+"</option>");
		}
  	});
}
function perGetVillageNameAndDep(){
	$("#perVillage").empty();
	$("#perVillage").append("<option value=''>--县、区--</option>");
	eval("var city = p"+$("#perCity").val());
	  	for(var i = 0; i < city.length; i++){
	  		var _value = city[i][0];
			if(perVillageVal && perVillageVal != '' && perVillageVal == _value){
				$("#perVillage").append("<option value="+city[i][0]+" selected='selected'>"+city[i][1]+"</option>");
			}else{
				$("#perVillage").append("<option value="+city[i][0]+">"+city[i][1]+"</option>");
			}
		}
	$("#perDep").empty();
	$("#perDep").append("<option value=''>--部&nbsp;门--</option>");
	var _perCityVal = $("#perCity").val();
	var _perVillage = $("#perVillage").val();
	var _code;
	if(_perVillage && _perVillage != ''){
		_code = _perVillage;
	}else{
		_code = _perCityVal;
	}
  	$.get(baseUrl+"/department/getDepsForAdSearch/"+_code, function(data){
  	  	var deps = eval(data);
  		for(var j = 0; j < deps.length; j++){
  			var _value = deps[j].depId;
			if(perDepVal && perDepVal != '' && perDepVal == _value){
				$("#perDep").append("<option value="+deps[j].depId+" selected='selected'>"+deps[j].departmentName+"</option>");
			}else{
				$("#perDep").append("<option value="+deps[j].depId+">"+deps[j].departmentName+"</option>");
			}
		}
  	});
};
function proGetVillageDep(){
	$("#proDep").empty();
	$("#proDep").append("<option value=''>--部&nbsp;门--</option>");
  	$.get(baseUrl+"/department/getDepsForAdSearch/"+$("#proVillage").val(), function(data){
  	  	var deps = eval(data);
  		for(var j = 0; j < deps.length; j++){
			$("#proDep").append("<option value="+deps[j].depId+">"+deps[j].departmentName+"</option>");
		}
  	});
}

function proGetVillageNameAndDep(){
	$("#proVillage").empty();
	$("#proVillage").append("<option value=''>--县、区--</option>");
	if($("#proCity").val() == ""){
    	return;
	}
	eval("var city = p"+$("#proCity").val());
	alert(proVillageVal);
	  	for(var i = 0; i < city.length; i++){
	  		var _value = city[i][0];
			if(proVillageVal && proVillageVal != '' && proVillageVal == _value){
				$("#proVillage").append("<option value="+city[i][0]+" selected='selected'>"+city[i][1]+"</option>");
			}else{
				$("#proVillage").append("<option value="+city[i][0]+">"+city[i][1]+"</option>");
			}
		}
	$("#proDep").empty();
	$("#proDep").append("<option value=''>--部&nbsp;门--</option>");
	var _proCityVal = $("#proCity").val();
	var _proVillage = $("#proVillage").val();
	var _code;
	if(_proVillage && _proVillage != ''){
		_code = _proVillage;
	}else{
		_code = _proCityVal;
	}
  	$.get(baseUrl+"/department/getDepsForAdSearch/"+_code, function(data){
  	  	var deps = eval(data);
  		for(var j = 0; j < deps.length; j++){
  			var _value = deps[j].depId;
			if(proDepVal && proDepVal != '' && proDepVal == _value){
				$("#proDep").append("<option value="+deps[j].depId+" selected='selected'>"+deps[j].departmentName+"</option>");
			}else{
				$("#proDep").append("<option value="+deps[j].depId+">"+deps[j].departmentName+"</option>");
			}
		}
  	});
};

function bevGetVillageDep(){
	$("#bevDep").empty();
	$("#bevDep").append("<option value=''>--部&nbsp;门--</option>");
  	$.get(baseUrl+"/department/getDepsForAdSearch/"+$("#bevVillage").val(), function(data){
  	  	var deps = eval(data);
  		for(var j = 0; j < deps.length; j++){
			$("#bevDep").append("<option value="+deps[j].depId+">"+deps[j].departmentName+"</option>");
		}
  	});
}
function bevGetVillageNameAndDep(){
	$("#bevVillage").empty();
	$("#bevVillage").append("<option value=''>--县、区--</option>");
	eval("var city = p"+$("#bevCity").val());
	  	for(var i = 0; i < city.length; i++){
	  		var _value = city[i][0];
			if(bevVillageVal && bevVillageVal != '' && bevVillageVal == _value){
				$("#bevVillage").append("<option value="+city[i][0]+" selected='selected'>"+city[i][1]+"</option>");
			}else{
				$("#bevVillage").append("<option value="+city[i][0]+">"+city[i][1]+"</option>");
			}
		}
	$("#bevDep").empty();
	$("#bevDep").append("<option value=''>--部&nbsp;门--</option>");
	var _bevCityVal = $("#bevCity").val();
	var _bevVillage = $("#bevVillage").val();
	var _code;
	if(_bevVillage && _bevVillage != ''){
		_code = _bevVillage;
	}else{
		_code = _bevCityVal;
	}
  	$.get(baseUrl+"/department/getDepsForAdSearch/"+_code, function(data){
  	  	var deps = eval(data);
  		for(var j = 0; j < deps.length; j++){
  			var _value = deps[j].depId;
			if(bevDepVal && bevDepVal != '' && bevDepVal == _value){
				$("#bevDep").append("<option value="+deps[j].depId+" selected='selected'>"+deps[j].departmentName+"</option>");
			}else{
				$("#bevDep").append("<option value="+deps[j].depId+">"+deps[j].departmentName+"</option>");
			}
		}
  	});
};

var intervalID;
var curLi;
	//打开DIV层
function openSearchBar(id,type){

	$.get(baseUrl+"/info/getAdSearchPage/"+id+"?type="+type, function(data){
		ymPrompt.win(data,530,440,'高级搜索');
		initAdSearch();
	});
}

var p510000 = [];
function initAdSearch(){
    var proCityVal = $('#proCityVal').val();
    var proVillageVal = $('#proVillageVal').val();
    var proDepVal = $('#proDepVal').val();

    var perCityVal = $('#perCityVal').val();
    var perVillageVal = $('#perVillageVal').val();
    var perDepVal = $('#perDepVal').val();

    var comCityVal = $('#comCityVal').val();
    var comVillageVal = $('#comVillageVal').val();
    var comDepVal = $('#comDepVal').val();
    
    var bevCityVal = $('#bevCityVal').val();
    var bevVillageVal = $('#bevVillageVal').val();
    var bevDepVal = $('#bevDepVal').val();
    $(".nav li a").mouseover(function(){
        curLi=$(this);
        intervalID=setInterval(onMouseOver,250);//鼠标移入的时候有一定的延时才会切换到所在项，防止用户不经意的操作
    });
    $(".nav li a").mouseout(function(){
        clearInterval(intervalID);
    });        
    
    $(".nav li a").click(function(){//鼠标点击也可以切换
        clearInterval(intervalID);
        $(".cur-sub-con").removeClass("cur-sub-con");
        $(".sub-con").eq($(".nav li a").index(curLi)).addClass("cur-sub-con");
        $(".cur").removeClass("cur");
        curLi.addClass("cur");                              
    });
    
    //项目高级搜索
    if(proCityVal && proCityVal != '' && proCityVal == '510000'){
    	$("#proCity").empty();
    	$("#proCity").append("<option value='510000' selected='selected'>省级</option>");
    	proGetVillageNameAndDep();
    }
     	for(var i = 0; i < provinceArr.length; i++){
      	var _value = provinceArr[i][0];
    	if(proCityVal && proCityVal != '' && proCityVal == _value){
    		$("#proCity").append("<option value="+provinceArr[i][0]+" selected='selected'>"+provinceArr[i][1]+"</option>");
    		proGetVillageNameAndDep();
    	}else{
    		$("#proCity").append("<option value="+provinceArr[i][0]+">"+provinceArr[i][1]+"</option>");
    	}
    }
    //人员高级搜索
    if(perCityVal && perCityVal != '' && perCityVal == '510000'){
    	$("#perCity").empty();
    	$("#perCity").append("<option value='510000' selected='selected'>省级</option>");
    	perGetVillageNameAndDep();
    }
     	for(var i = 0; i < provinceArr.length; i++){
      	var _value = provinceArr[i][0];
    	if(perCityVal && perCityVal != '' && perCityVal == _value){
    		$("#perCity").append("<option value="+provinceArr[i][0]+" selected='selected'>"+provinceArr[i][1]+"</option>");
    		perGetVillageNameAndDep();
    	}else{
    		$("#perCity").append("<option value="+provinceArr[i][0]+">"+provinceArr[i][1]+"</option>");
    	}
    }
    //企业高级搜索
    if(comCityVal && comCityVal != '' && comCityVal == '510000'){
    	$("#comCity").empty();
    	$("#comCity").append("<option value='510000' selected='selected'>省级</option>");
    	comGetVillageNameAndDep();
    }
     	for(var i = 0; i < provinceArr.length; i++){
      	var _value = provinceArr[i][0];
    	if(comCityVal && comCityVal != '' && comCityVal == _value){
    		$("#comCity").append("<option value="+provinceArr[i][0]+" selected='selected'>"+provinceArr[i][1]+"</option>");
    		comGetVillageNameAndDep();
    	}else{
    		$("#comCity").append("<option value="+provinceArr[i][0]+">"+provinceArr[i][1]+"</option>");
    	}
    }
    
 	//企业高级搜索
    if(bevCityVal && bevCityVal != '' && bevCityVal == '510000'){
    	$("#bevCity").empty();
    	$("#bevCity").append("<option value='510000' selected='selected'>省级</option>");
    	bevGetVillageNameAndDep();
    }
     	for(var i = 0; i < provinceArr.length; i++){
      	var _value = provinceArr[i][0];
    	if(bevCityVal && bevCityVal != '' && bevCityVal == _value){
    		$("#bevCity").append("<option value="+provinceArr[i][0]+" selected='selected'>"+provinceArr[i][1]+"</option>");
    		bevGetVillageNameAndDep();
    	}else{
    		$("#bevCity").append("<option value="+provinceArr[i][0]+">"+provinceArr[i][1]+"</option>");
    	}
    }
     
}